import  api from '../../http/api'

export default{
    namespaced: true,
    state:{
        detailsData:[],
        pages: 2,
        total: 10,
        pagesize: 4,
        startpage: 1,
        list:[],
    },
    mutations:{

        setGetDataById(state,newData){
            state.detailsData=[newData]
            console.log(1233333,state.detailsData)
        },
        searchData(state,newData){
            state.list=newData.list
            console.log('搜索数据',state.list)
        },

        setStartpageData(state,newData){
            state.pages=newData.pages
            state.total=newData.total
            state.list=newData.list
            console.log(state.list);
        },

    },
    actions:{
        async getOrder(context){
            const data = await api.order.getOrder({
                pagesize:context.state.pagesize,
                startpage:context.state.startpage
            })
           
            if(data.data.code==200){
                context.commit('setStartpageData',data.data.object)
            }
        },
        async getOrderById(context ,id){
            
            const data = await api.order.getOrderById({id});
            console.log('个人数据',data)
            if(data.data.code == 200){
                context.commit('setGetDataById',data.data.object)
            }

            // return data
           
        },
        async search(context,nfuhTotalorderDto){
            console.log(nfuhTotalorderDto);
            const data = await api.order.search(nfuhTotalorderDto)
            console.log(data);
            if(data.data.code==200){
                context.commit('searchData',data.data.object)
            }
        }
    }
}